package com.snow.dayou.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * @Auther: yanke
 * @Date: 2018/10/9 0009 16:00
 * @Description:设置填充字段的填充类型
 */
@Component
public class MybatisObjectHandler implements MetaObjectHandler {

    private final static String CREATETIME = "createTime";

    @Override
    public void insertFill(MetaObject metaObject) {
//        this.setFieldValByName(CREATETIME, new Date(), metaObject);
        //新增时填充的字段
//        autoValue("createTime", new Date(), metaObject, subject, null);
//        autoValue("updateTime", new Date(), metaObject, subject, null);
//        autoValue("createUserId", null, metaObject, subject, 1);
//        autoValue("updateUserId", null, metaObject, subject, 1);
////        autoValue("createUserName", null, metaObject, subject, 2);
////        autoValue("updateUserName", null, metaObject, subject, 2);
////        autoValue("commonStatus", 0, metaObject, subject, null);
//        autoValue("isDel", 0, metaObject, subject, null);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        //更新时 需要填充字段
//        autoValue("updateTime", new Date(), metaObject, subject, null);
//        autoValue("updateUserId", null, metaObject, subject, 1);
//        autoValue("updateUserName", null, metaObject, subject, 2);
    }
}
